package com.gibs.peixunapi.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import com.gibs.peixunapi.model.Documentation;

@Repository
public interface DocumentationDao extends JpaRepository<Documentation, Integer>, JpaSpecificationExecutor<Documentation> {

	@Query("from Documentation where name = ?1")
	List<Documentation> find(String name);

	@Query("from Documentation where name like ?1")
	List<Documentation> findLike(String name);

	@Query(value = "select * from Documentation limit ?, ?", nativeQuery = true)
	List<Documentation> findPage(Integer offset, Integer size);

	@Query(value = "select * from Documentation where name = ? limit ?, ?", nativeQuery = true)
	List<Documentation> findPage(String name, Integer offset, Integer size);

	@Query(value = "select * from Documentation where name like ? limit ?, ?", nativeQuery = true)
	List<Documentation> findPageLike(String name, Integer offset, Integer size);

	@Query(value = "select count(*) from Documentation where name = ?", nativeQuery = true)
	Long count(String name);

	@Query(value = "select count(*) from Documentation where name like ?", nativeQuery = true)
	Long countLike(String name);
	
	@Query("from Documentation order by id asc")
	List<Documentation> findAllAsc();
}

